/*
 *  TileField.cpp
 *  powaah
 *
 *  Created by Tim Uusitalo on 4/20/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */

#include "TileField.h"

TileField::TileField(const int tile_size, const Vector2& dimensions)
{
	tiles.reserve(dimensions.x * dimensions.y);
	
	int max_x = dimensions.x;
	int max_y = dimensions.y;
	
	for (int y = 0; y < max_y; y+=tile_size)
	{
		for (int x = 0; x < max_x; x+=tile_size)
		{
			tiles.push_back(Tile(Vector2(x,y), 0.0f));
		}
	}
	
	
	this->tile_size = tile_size;
	this->dimensions = dimensions;
}

TileField::~TileField()
{
}

void TileField::insertCharge(const float charge, const Vector2& pos, const Vector2& dim)
{
	Tile& tile = getTile(pos.x, pos.y);

	if (dim.y > tile_size)
	{
		
	}
	else if (dim.x > tile_size)
	{
		
	}
	
	
}

Tile& TileField::getTile(const float x, const float y)
{
	return tiles[y * (int)dimensions.x + x];
}